home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / graphics / amicad / arexx / tirertraits.amicad < prev    next >
Text File  |  1999-12-06  |  4KB  |  208 lines

  1. /* Décalage et alignement des extrémités d'un ensemble de lignes */
  2. /* Version 1.00 13/01/99 */
  3. /* Version 1.01 06/02/99, Ajout UNLOCK */
  4. /* Version 1.02 16/03/99, modif macro LIGNE */
  5. /* Version 1.03 22/09/99, correction bug si annulation GETPOINT (ajout UNLOCK) */
  6. /* $VER: 1.03 (© R.Florac, 22/09/99) */
  7. options results
  8.  
  9. signal on error
  10. signal on syntax
  11.  
  12. 'DEF LIGNE(P)=P&0X07FFF'
  13. 'DEF COLONNE(P)=P>>15'
  14. 'LOCK(-1):SELECT("Extrémité à déplacer?"+CHR(10)+"Gauche"+CHR(10)+"Haut"+CHR(10)+"Droite"+CHR(10)+"Bas")'
  15. d=result
  16. select
  17.     when d=1 then do
  18.     'GETPOINT("Cliquez sur la colonne de destination")'; p=result
  19.     if p<0 then do
  20.         'UNLOCK(-1)'
  21.         exit
  22.     end
  23.     'COLONNE('p')'; col=result
  24.     'SAVEALL(-1):FIRSTSEL'; o=result
  25.     do while o>0
  26.         mode=mode_ligne(o)
  27.         if mode~=-1000 then do
  28.         o = retracer_gauche(o,col,mode)
  29.         end
  30.         else do
  31.         'NEXTSEL('o')'; o=result
  32.         end
  33.     end
  34.     end
  35.     when d=2 then do
  36.     'GETPOINT("Cliquez sur la ligne de destination")'; p=result
  37.     if p<0 then do
  38.         'UNLOCK(-1)'
  39.         exit
  40.     end
  41.     'LIGNE('p')'; ligne=result
  42.     'SAVEALL(-1):FIRSTSEL'; o=result
  43.     do while o>0
  44.         mode=mode_ligne(o)
  45.         if mode~=-1000 then do
  46.         o = retracer_haut(o,ligne,mode)
  47.         end
  48.         else do
  49.         'NEXTSEL('o')'; o=result
  50.         end
  51.     end
  52.     end
  53.     when d=3 then do
  54.     'GETPOINT("Cliquez sur la colonne de destination")'; p=result
  55.     if p<0 then do
  56.         'UNLOCK(-1)'
  57.         exit
  58.     end
  59.     'COLONNE('p')'; col=result
  60.     'SAVEALL(-1):FIRSTSEL'; o=result
  61.     do while o>0
  62.         mode=mode_ligne(o)
  63.         if mode~=-1000 then do
  64.         o = retracer_droite(o,col,mode)
  65.         end
  66.         else do
  67.         'NEXTSEL('o')'; o=result
  68.         end
  69.     end
  70.     end
  71.     when d=4 then do
  72.     'GETPOINT("Cliquez sur la ligne de destination")'; p=result
  73.     if p<0 then do
  74.         'UNLOCK(-1)'
  75.         exit
  76.     end
  77.     'LIGNE('p')'; ligne=result
  78.     'SAVEALL(-1):FIRSTSEL'; o=result
  79.     do while o>0
  80.         mode=mode_ligne(o)
  81.         if mode~=-1000 then do
  82.         o = retracer_bas(o,ligne,mode)
  83.         end
  84.         else do
  85.         'NEXTSEL('o')'; o=result
  86.         end
  87.     end
  88.     end
  89.     otherwise nop
  90. end
  91. 'UNLOCK(-1)'
  92. exit
  93.  
  94. mode_ligne: procedure
  95.     parse arg o
  96.     mode=-1000
  97.     'TYPE('o')'
  98.     select
  99.     when result=2 then mode=1   /* fil */
  100.     when result=15 then mode=2  /* ligne double */
  101.     when result=9 then mode=3   /* bus */
  102.     when result=8 then mode=0   /* pointillés */
  103.     when result=21 then do        /* ligne spéciale */
  104.         'PENWIDTH('o',-10000)'
  105.         mode=0-result
  106.     end
  107.     otherwise nop
  108.     end
  109.     return mode
  110.  
  111. minima: procedure
  112.     parse arg v1,v2
  113.     if v1<v2 then return v1
  114.     return v2
  115. end
  116.  
  117. maxima: procedure
  118.     parse arg v1,v2
  119.     if v1>v2 then return v1
  120.     return v2
  121. end
  122.  
  123. retracer_gauche: procedure
  124.     parse arg o,col,mode
  125.     'COORDS('o')'
  126.     PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  127.     xg=minima(x0,x1)
  128.     if x0=x1 then x1=col
  129.     if xg=x0 then do
  130.     x2=x1; y2=y1;
  131.     end
  132.     else do
  133.     x2=x0; y2=y0; y0=y1
  134.     end
  135.     'DELETE('o'):DRAWMODE('mode'):DRAW('col','y0','x2','y2')'; no=result
  136.     if no=o then o=0
  137.     else do
  138.     'NEXTSEL('o-1')'; o=result
  139.     end
  140.     return o
  141.  
  142. retracer_haut: procedure
  143.     parse arg o,ligne,mode
  144.     'COORDS('o')'
  145.     PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  146.     yh=minima(y0,y1)
  147.     if y0=y1 then y1=ligne
  148.     if yh=y0 then do
  149.     y2=y1; x2=x1;
  150.     end
  151.     else do
  152.     y2=y0; x2=x0; x0=x1
  153.     end
  154.     'DELETE('o'):DRAWMODE('mode'):DRAW('x0','ligne','x2','y2')'; no=result
  155.     if no=o then o=0
  156.     else do
  157.     'NEXTSEL('o-1')'; o=result
  158.     end
  159.     return o
  160.  
  161. retracer_droite: procedure
  162.     parse arg o,col,mode
  163.     'COORDS('o')'
  164.     PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  165.     xd=maxima(x0,x1)
  166.     if x0=x1 then x0=col
  167.     if xd=x1 then do
  168.     x2=x0; y2=y0; y0=y1
  169.     end
  170.     else do
  171.     x2=x1; y2=y1
  172.     end
  173.     'DELETE('o'):DRAWMODE('mode'):DRAW('x2','y2','col','y0')'; no=result
  174.     if no=o then o=0
  175.     else do
  176.     'NEXTSEL('o-1')'; o=result
  177.     end
  178.     return o
  179.  
  180. retracer_bas: procedure
  181.     parse arg o,ligne,mode
  182.     'COORDS('o')'
  183.     PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  184.     yb=maxima(y0,y1)
  185.     if y0=y1 then y1=ligne
  186.     if yb=y0 then do
  187.     y2=y1; x2=x1;
  188.     end
  189.     else do
  190.     y2=y0; x2=x0; x0=x1
  191.     end
  192.     'DELETE('o'):DRAWMODE('mode'):DRAW('x0','ligne','x2','y2')'; no=result
  193.     if no=o then o=0
  194.     else do
  195.     'NEXTSEL('o-1')'; o=result
  196.     end
  197.     return o
  198.  
  199. /* Traitement des erreurs, interruption du programme */
  200. syntax:
  201. erreur=RC
  202. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'"):UNLOCK(-1)'
  203. exit
  204.  
  205. error:
  206. 'MESSAGE("Erreur en ligne 'SIGL'"):UNLOCK(-1)'
  207. exit
  208.